#include <ros/ros.h>
#include "ros_test_pkg/mySrv.h"

int main(int argc,char **argv)
{
    ros::init(argc,argv,"client_node");
    ros::NodeHandle handle;
    ros_test_pkg::mySrv srv;

    ros::Rate rate(0.5);
    ros::ServiceClient client = handle.serviceClient<ros_test_pkg::mySrv>("sum_service");

    while(ros::ok())
    {
        srv.request.num_a = rand()%100;
        srv.request.num_b = rand()%100;
        ROS_INFO("Client request:%d %d",srv.request.num_a,srv.request.num_b);

        if(client.call(srv))
        {
            ROS_INFO("server response:%s",srv.response.str.c_str());
            ROS_INFO("----------------------------------");
        }
        else{
            ROS_ERROR("request error !");
            return 1;
        }
        ros::spinOnce();
        rate.sleep();
    }

    return 0;
}